//index.js
//获取应用实例
const app = getApp()
let Axios = require('../../../common/js/ajax.js');
let Mtils = require('../../../common/js/Mtils.min.js');
Mtils = Mtils.Mtils
Page({
	data: {
		openid: '',
		nickName: '',
		avatarUrl: '',
		curentNav: 2, //当前导航
		message_id: 0,
		info: {}
	},
	//事件处理函数
	onLoad: function(e) {
		var _this = this;
		this.uid = app.globalData.uid || ''
		this.Md5 = Mtils.security.hex_md5(this.uid) + app.globalData.secret;
		this.Md5 = Mtils.security.hex_md5(this.Md5);
		this.timesp = Mtils.now();
		this.setData({
			message_id: e.id
		})
		Axios.get(app.globalData.baseUrl + 'App/Message/Message/bond_content', {
			uid: this.uid,
			time: this.timesp,
			sign: this.Md5,
			message_id: this.data.message_id
		}, (res) => {
			console.log(res)
			if (res.status == 1) {
				var data = res.info
				_this.setData({
					info: data
				})
			} else {
				_this.showModal(res)
			}
		})

		if (app.globalData.nickName && app.globalData.avatarUrl) {
			this.setData({
				nickName: app.globalData.nickName,
				avatarUrl: app.globalData.avatarUrl
			})
		}
	},
	onReady: function() {
		wx.setNavigationBarTitle({
			title: '保证金领取'
		})
	},
	handlelqTap: function() {
		var _this = this;
		Axios.get(app.globalData.baseUrl + 'App/Message/Message/bond_receive', {
			uid: this.uid,
			time: this.timesp,
			sign: this.Md5,
			message_id: this.data.message_id
		}, (res) => {
			console.log(res)
			if (res.status == 1) {
				var data = res.info
				_this.setData({
					'info.is_receive': 1
				})
				_this.showModal(res)
			} else {
				_this.showModal(res)
			}
		})
	},
	showModal: function(error) {
		wx.showModal({
			content: error.msg,
			showCancel: false,
		})
	},
})
